# -*- coding:utf-8 -*-
class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None

class Solution:
    def FindKthToTail(self, head):
        # write code here
        if head==0:
            return None
        l = f = head
        count = 1
        while f.next!=None and f.next.next!=None:
            f = f.next.next
            l = l.next
            count+=2
        print(count)
        if count%2==1:
            return l.val
        else:
            return l.next.val
        # return l.val




node1 = ListNode(1)
node2 = ListNode(2)
node3 = ListNode(3)
node4 = ListNode(4)
node5 = ListNode(5)
node6 = ListNode(6)
node7 = ListNode(7)
node8 = ListNode(7)
node1.next = node2
node2.next = node3
node3.next = node4
node4.next = node5
node5.next = node6
node6.next = node7
node7.next = node8


s = Solution()
m= s.FindKthToTail(node1)
print(m)